/**
 * 
 * @author JackChu
 * @version 2012-6-13 下午11:21:18
 */
package jjk.model
{

	public class Grid
	{
		public var cols:int;//列x
		public var rows:int;//行y
		
		private var _nodes:Array = [];
		
		public function Grid(cols:int,rows:int)
		{
			this.cols = cols;
			this.rows = rows;
			initGrid();
		}
		
		private function initGrid():void
		{
			for(var c:int=0;c<rows;c++)
			{
				_nodes[c] = [];
				for (var l:int = 0; l < cols; l++) 
				{
					_nodes[c][l] = new Node(c,l);					
				}
			}
		}		
		
		public function setUnCrossable(x:int,y:int):void
		{
			var node:Node =_nodes[x][y];
			node.crossable = false;
		}
		
		public function setCrossable(x:int,y:int):void
		{
			var node:Node =_nodes[x][y];
			node.crossable = true;
		}
		
		public function getNode(x:int,y:int):Node 
		{
			return _nodes[x][y];
		}
		
	}
}